/**
 * Created by Administrator on 2017/5/20.
 */

var $html      = $('html'),
    $music     = $('.music'),
    $audio     = $('audio')[0],
    $navIcon   = $('.back-start'),
    $parentBox = $('.homepage, .diy-desk-box, .get-wine-box, .ranking-box, .desk-box, .way3-box, .into-box, .my-box'),
    $childBox  = $('.rule, .diy-box, .get-wine, .lately-map, .exchange-box, .award-box'),
    $wrapper   = $('.zoom-in'),
    $add       = $('.wrapper-add'),
    $tips      = $('.tips');

// rem布局
$html.css('font-size',$html.height()/504*16);
$html.height($html.height());

//右上角音乐
$music.on('click',function () {
    $(this).toggleClass('icon-music icon-disable');
    $(this).hasClass('icon-music')?$audio.play():$audio.pause();
});

//右下角返回主页
$navIcon.on('click',function () {
    $(this).fadeOut();
    $parentBox.css('transform','translateY(0)').one('transitionend',function () {
        $childBox.css('transform','translateY(0)');
        $('#location-pop .close').click();
    });
    $('.map > div').removeClass('pro-animate');
});

//弹窗
function showPop(popBox) {
    $(popBox).fadeIn();
    $(popBox).find('.pop_up').addClass("popshow");
}
$(".back .close").on("click",function(){
    $(this).parents('.back').fadeOut();
    $(this).parent().removeClass("popshow");
});

//初始化桌椅布局
function deskLayout(parent,child) {
    var r=$(parent).width()/2,
        c=$(child).eq(0).width()/2,
        top,left;
    $(child).each(function (i) {
        top  = Math.sin((i*60-90)*(Math.PI/180))*r+r-c;
        left = Math.cos((i*60-90)*(Math.PI/180))*r+r-c;
        $(this).css({'top':top,'left':left});
    });
}
setTimeout(function () {
    deskLayout('.wrapper-big','.wrapper-big .circle');
    deskLayout('.wrapper','.wrapper .circle');
},1000);

var $wrapperC = $wrapper.clone();
//初始化加5个
for(var i=0;i<4;i++){
    $add.before($wrapper.clone());
    $('.zoom-in em:last').html(i+2);
}
